import {REQUEST_URL,FIELD, CARD_ADD_DISABLED_BUTTON, CARD } from "../../constant";
import {ajax,getBusinessInfo} from 'nc-lightapp-front';
/**
* @description: 表头编辑后事件
* @param: moduleId 区域编码
* @param: key 当前字段编码
*/
export function afterHeadEvent(props, moduleId, key, value, oldValue) {
        if (key === FIELD.org) {
                props.resMetaAfterPkorgEdit(); //选择主组织以后，恢复其他字段的编辑性
                props.button.setButtonDisabled(CARD_ADD_DISABLED_BUTTON, false);//恢复增行编辑性
                props.cardTable.setAllCheckboxAble(CARD.table_code, true);
                let msg = getBusinessInfo();
                ajax({
                        url: REQUEST_URL.queryUserMsg,
                        data: msg.userId,
                        success: (res) => {
                                props.form.setFormItemsValue(CARD.form_id, {[FIELD.org]: {value : res.data.pk_org, display: res.data.en}});
                                props.form.setFormItemsValue(CARD.form_id, {[FIELD.dept]: {value : res.data.pk_dept, display: res.data.name}});
                                props.form.setFormItemsValue(CARD.form_id, {[FIELD.maker]: {value : res.data.pk_psndoc, display: res.data.bn}});
                        }
                });
        }
}
